package com.foreknow.service.impl;

import com.foreknow.dao.AdminDao;
import com.foreknow.dao.impl.AdminDaoImpl;
import com.foreknow.db.DBManager;
import com.foreknow.model.Admin;
import com.foreknow.service.AdminService;

import java.sql.Connection;

public class AdminServiceImpl implements AdminService {

    @Override
    public Admin isValidate(String username, String password) {
        //1. 连接数据库
        DBManager dbManager = DBManager.getInstance();
        Connection conn = dbManager.getConnection();
        //2. 注入数据库的连接
        AdminDaoImpl adminDao = new AdminDaoImpl();
        adminDao.setConnection(conn);
        //3. 调用dao中的方法
        return adminDao.isLogin(username,password);
    }

    public static void main(String[] args) {
        AdminService service = new AdminServiceImpl();
        Admin admin = service.isValidate("fender","123456");
        System.out.println(admin.getUsername());
    }
}
